using System;
using System.Collections.Generic;
using System.Text;
 using NUnit.Framework;
using System.Data.SqlClient;
using System.Data;
using PHSRAG.Insight21.Purchasing;
using PHSRAG.Insight21.SearchContext;
using System.Configuration;


namespace InsightTest.Purchasing
{
    [TestFixture]
   public class PurchasTest: BaseTest
    {
        public PurchasTest()
        { 
        
        }
        static SqlConnection sqlConn;
        [SetUp]
        public void Init()
        {

            try
            {
               // Below is just an example we can setup code here
               if(sqlConn == null)
               {
                   ;//sqlConn = new SqlConnection(sqlConnectionString);
               }

             

            }
            catch (Exception x)
            {

                //just take a peek
                string _message = x.InnerException.Message;          

            }
        }

        [TearDown]
        public void Dispose()
        {
            if (sqlConn != null)
            {
                if (sqlConn.State == ConnectionState.Open)
                {
                    sqlConn.Close();
                }
                sqlConn = null;
            }

        }
        #region Tests

        [Test]
        public void GetAllPOAPSummary()
        {
            try
            {

                
                #region POOAP Search criteria, right now this is not being used
                int domainUserID = 3129;
                string poNumber = "555";
                string voucherNumber = null;
                int orderTypeId = 0;
                int vendorId = 0;
                string vendorName = "";
                int fundId = 0;
                string fundNumber = "";
                string requestorName = "";
                int piId = 0;
                int labId = 0;
                string accountNumber = "";
                int accountCategoryId = 0;
                string requisitionNumber = "";
                int expenseStatus = 0;
                string invoiceNumber = "";
                string journalNumber = "";
                int transactionType = 0;
                DateTime transactionTypeFrom = DateTime.Now;
                DateTime transactionTypeTo = DateTime.Now;
                string enteredBy = "";
                int locationId = 0;
                string chiefCodeList = "";

                int includeProgramProjects = 0; 

                string folderNumber = "";
                string bicsNumber = "";
                string walkerNumber = "";
                string sponsorNumber = "";

                string sponsorName = "";
                int sponsorTypeId = 0;
                int agreementTypeId = 0;
                string activityCode = "";
                DateTime budgetStartDate = DateTime.Now;

                DateTime budgetEndDate = DateTime.Now;
                DateTime projectStartDate = DateTime.Now;
                DateTime projectEndDate = DateTime.Now;
                int sponsorGroupTypeId = 0;
                int budgetEndingDays = 0;


                int projectEndingDays = 0;
                int daysFundCreated = 0;
                decimal lowBalance = 0;
                decimal highBalance = 0;
                string agreementStatusTypeList = "";

                int FundStatusTypeId = 0;
                int accessBitMask = 512;
                #endregion

                //Provide some valid user ID as serach criteria always gets initialized with user ID.
                SearchCriteria commonSearchCriteria = new SearchCriteria(182029);
                POAPSummaries poAPSummaries = new POAPSummaries();
                /* This is repilcation of 
                 *transactionSummaries.Load(
						Utility.DataAccess.ConnectionString, Session.SessionID
						,commonSearchCriteria,  IncomingFundNumber, accessBitMask
				
                 * ,searchContext.CurrentModule, ignoreFundStatus, ignoreAgreementStatus);
                   This method is used for loading poap summaries
                 */
                
                poAPSummaries.Load(sqlConnectionString, "sessionid", commonSearchCriteria,
                    null, accessBitMask, "Purchasing", true, true);
                DataSet dsPurchase = poAPSummaries.GetDataContainer();

                Assert.GreaterOrEqual( dsPurchase.Tables[0].Rows.Count, 0,  "At least one record is available" );
             
            }
            catch (Exception ex)
            {

                System.Diagnostics.EventLog.WriteEntry("InsightTest", ex.InnerException.ToString());
            }

        }
        #endregion

    }
}
